var task_id = GetQueryString('task_id');
var modifyData;
var qxlist;
var dhbm = dhbm_sjcj;
var readflag = true;
var processDefKey = "minbocaiji";
$(document).ready(function() {
	getUserInfo();
	qxlist = UserInfo.qxlist;
	var result = ajaxResult("get",false,"/cnmuseum/cj/getdetail",{"task_id":task_id});
	if (result.status == 'OK') {
		modifyData = result.data;
		loadAddHtml();
	}
	//$('#addForm input').attr('readonly', 'true');
	//$('#addForm textarea').attr('readonly', 'true');
	//$('#addForm select').attr('disabled', 'disabled');
	//$('#addForm button').attr('disabled', 'disabled');
	//$("#assigneeview").removeAttr("readonly");
});
function selectZj() {
	var expertColumns = [
			{
				title : '选择',
				formatter : function(value, row, index) {
					return '<input name="expertId" type="checkbox" value="'
							+ row.zdbh + '" />';
				}
			}, {
				title : '专家名称',
				field : 'xm',
				width : 50
			}, {
				title : '所在机构',
				field : 'szjg'
			}, {
				title : '研究特长',
				field : 'yjtc'
			} ];
	createTable('#userInfo', '../../mbXtglZjkServlet.getZjkUser.do', 'zdbh',expertColumns, null, null);
	$("#nextExpertModal").modal('show');
}

// 提交
function submit(nextstep,ele) {
	$("a[name=btn]").button('loading').delay(1000).queue(function() {
		$("a[name=btn]").button('reset');
		$("a[name=btn]").dequeue(); 
	});
	$(ele).button('loading').delay(1000).queue(function() {
		$(ele).button('reset');
		$(ele).dequeue(); 
		
		if (nextstep == '') {
			alertFunc('下一步骤不能为空');
			return;
		}
		// 验证
		if (valid(nextstep)) {
			// 获取参数
			var params = getParams(nextstep);
			// 提交
			var result = ajaxResult('POST', false,'/cnmuseum/cj/submit',params);
			if (result.status == 'OK') {
				alertFunc('提交成功', function() {
					location.href = 'sjcj.html';
				});
			}
		}
	});

}
function getParams(nextstep) {
	var params = {};
	var params=$('#addForm').serializeObject();
	if (nextstep == 'zjlr') {
		var assigneeuser = new Array;// =$("input[name='expertId']:checked").val();
		$.each($("input[name='expertId']:checked"), function(index, data) {
			assigneeuser.push(data.value);
		});
		params.nextids=assigneeuser.toString();
		params.next='lr';
	} else if (nextstep == 'tjsh') {
		params.next = 'sh';
	}
	return params;
}
function valid(nextstep) {
	if (nextstep == 'zjlr') {
		var assigneeuser = new Array;// =$("input[name='expertId']:checked").val();
		$.each($("input[name='expertId']:checked"), function(index, data) {
			assigneeuser.push(data.value);
		});
		if (!checkExpert(assigneeuser,dhbm_cjlr)) {
			return true;
		} else {
			alertFunc('所选择的专家有权限重复，请重新选择！');
		}
		return false;

	} else
		return true;
}
